#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
string s, t;
bool solve() {
  cin >> n;
  cin >> s >> t;
  for (int i = 1; i < n; i += 2) swap(s[i], t[i]);
  int cnt = 0;
  // check s
  rep(i, 0, n - 1) if (s[i] == '0') cnt++;
  if (cnt < (n + 1) / 2) return false;
  cnt = 0;
  // check t
  rep(i, 0, n - 1) if (t[i] == '0') cnt++;
  if (cnt < n / 2) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    bool res = solve();
    cout << (res ? "YES\n" : "NO\n");
  }
  return 0;
}